package fy.mdm.operator;

import java.util.ArrayList;
import java.util.List;

import com.seeyon.v3x.services.flow.bean.FlowExport;
import com.seeyon.v3x.services.form.bean.ValueExport;

import fy.form.listen.operate.AForm_Save_Operator;
import fy.form.listen.operate.IFormOperator;
import fy.mdm.bean.FiexdAssetBean;
import fy.mdm.dao.FiexdAssetReviewDao;


public class FiexdAssetsFormOperator extends AForm_Save_Operator implements IFormOperator{
	private FiexdAssetBean bean=new FiexdAssetBean();
	private List<String> numberList = new ArrayList<String>();

	@Override
	public String getFormName() {
		// TODO Auto-generated method stub
		return "固定资产验收单";
	}

	@Override
	protected void parseOtherField_FirstStep(FlowExport flowExport) {//第一步
		bean.setSummaryId(super.formBean.getSummaryId());
		bean.setBillname(flowExport.getFlowTitle());
		bean.setApplier(flowExport.getFlowCreatePerson().getName());
		bean.setTs(flowExport.getFlowCreateTime());
		
	}

	@Override
	protected void parseValueExport(ValueExport ve) {

		String fieldName = ve.getDisplayName();
		if ("项目名称".equals(fieldName)) {//业务类型
			bean.setBusiness(ve.getValue());
		} else if ("设备类型".equals(fieldName)) {//资产类型
			bean.setAssettypes(ve.getValue());
		} 
		else if ("固定资产编号".equals(fieldName)) {
			bean.setAssetnumbers(ve.getValue());
		}
		
//		else if ("公司名称".equals(fieldName)) {//子公司
//			bean.setSubsidiary(ve.getValue());
//		} 
		else if ("设备条码".equals(fieldName)) {
//			bean.setEquipmentcode(ve.getValue());
			this.numberList.add(ve.getValue());
		}  
//		else if ("供应商".equals(fieldName)) {
//			bean.setSupplier(ve.getValue());
//		} 
//		else if ("数量".equals(fieldName)) {
//			bean.setNumber(ve.getValue());
//		} 
	}
		
	

	@Override
	protected boolean save() {

		try {
			bean.setNumberList(this.numberList);
			FiexdAssetReviewDao fiexdAssetReviewDao = new FiexdAssetReviewDao();
			fiexdAssetReviewDao.setFiexdAssetBean(bean);
			return fiexdAssetReviewDao.StateReturn();
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			//bean.clear();
				bean = null;
			}
		return success;
	}

}
